package com.example.love_margin.Controller;


import com.example.love_margin.Entity.Test;
import com.example.love_margin.Mapper.AdoptMapper;
import com.example.love_margin.Mapper.PetMapper;
import com.example.love_margin.Mapper.SearchMapper;
import com.example.love_margin.Service.TestService;
import com.example.love_margin.Untils.ResultCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@Api(value = "测试接口",tags = "测试接口")
@RestController
@RequestMapping(value = "/Test",name = "测试返回")

public class TestController {

    @Autowired
    TestService testService;

    @Autowired
    AdoptMapper adoptMapper;

    //增加信息
    @ApiOperation(value = "增加信息",notes = "增加信息")
   //    @PostMapping(value = "/addTest",produces = "application/json")
    @PostMapping(value = "/addTest")
//    @RequestMapping(value = "/addTest",method = RequestMethod.POST,produces = "multipart/form-data")
    public Object addTest(@RequestBody Test t, @RequestParam(value = "file",required = false)MultipartFile file){
        return testService.addTest(t,file);
    }

    //删除信息
    @ApiOperation(value = "删除信息",notes = "删除信息")
    @PostMapping(value = "/deleteTest")
    public Object deleteTest(@RequestParam int id){
        return "success";
    }

    //id查询信息,返回name,age,sex,message,time,url
    @ApiOperation(value = "id查询详情",notes = "id查询详情")
    @GetMapping(value = "/selectTest1")
    public Object select1Test1(@RequestParam int id){
        return "";
    }

    //列表查询，返回name,age,sex,time,url,    //如果传
    // 0输id，则根据id加一查询后十条数据
    @ApiOperation(value = "全部查询",notes = "全部查询")
    @GetMapping(value = "selectTest2")
    public Object selectTest2(){
        return testService.select();
    }

    //多条件查询

    @Autowired
    PetMapper petMapper;

    @ApiOperation(value = "多条件查询",notes = "类别，品种，性别分类查询")
    @PostMapping(value = "/selectTest3")
     public Object selectTest3(@RequestBody Test y){
//        return testService.select1(y);
        return ResultCode.SUCCESS.result(adoptMapper.selectAdoptPets(3));
     }

}